package com.findFish.water.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.water.domain.WaterQuality;
import com.findFish.water.service.IWaterQualityService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 水质监测数据Controller
 * 
 * @author admin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/water/quality")
public class WaterQualityController extends BaseController
{
    @Autowired
    private IWaterQualityService waterQualityService;

    /**
     * 查询水质监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('water:quality:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaterQuality waterQuality)
    {
        startPage();
        List<WaterQuality> list = waterQualityService.selectWaterQualityList(waterQuality);
        return getDataTable(list);
    }

    /**
     * 导出水质监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('water:quality:export')")
    @Log(title = "水质监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaterQuality waterQuality)
    {
        List<WaterQuality> list = waterQualityService.selectWaterQualityList(waterQuality);
        ExcelUtil<WaterQuality> util = new ExcelUtil<WaterQuality>(WaterQuality.class);
        util.exportExcel(response, list, "水质监测数据数据");
    }

    /**
     * 获取水质监测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('water:quality:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(waterQualityService.selectWaterQualityById(id));
    }

    /**
     * 新增水质监测数据
     */
    @PreAuthorize("@ss.hasPermi('water:quality:add')")
    @Log(title = "水质监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaterQuality waterQuality)
    {
        return toAjax(waterQualityService.insertWaterQuality(waterQuality));
    }

    /**
     * 修改水质监测数据
     */
    @PreAuthorize("@ss.hasPermi('water:quality:edit')")
    @Log(title = "水质监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaterQuality waterQuality)
    {
        return toAjax(waterQualityService.updateWaterQuality(waterQuality));
    }

    /**
     * 删除水质监测数据
     */
    @PreAuthorize("@ss.hasPermi('water:quality:remove')")
    @Log(title = "水质监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(waterQualityService.deleteWaterQualityByIds(ids));
    }
}
